package com.itic.appbase.framework.plugins.mybatis.dialect.db;

import com.itic.appbase.framework.plugins.mybatis.Page;
import com.itic.appbase.framework.plugins.mybatis.dialect.Dialect;

public class OracleDialect
        implements Dialect {

    @Override
    public String buildPageSql(String sql, Page page) {
        StringBuilder pageSql = new StringBuilder(100);
        String beginrow = String.valueOf(page.getRecordNow());
        String endrow = String.valueOf(page.getRecordNow() + page.getPageSize());
        pageSql.append("select * from ( select temp.*, rownum row_id from ( ");
        pageSql.append(sql);
        pageSql.append(" ) temp where rownum <= ").append(endrow);
        pageSql.append(") where row_id > ").append(beginrow);
        return pageSql.toString();
    }

}
